package com.itheima.controller;

import com.alibaba.nacos.api.exception.NacosException;
import com.itheima.model.OrderInfo;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author：shenkunlin
 * @date： 2021/7/5 11:42
 * @Description：
 ***/
@RestController
@RequestMapping(value = "/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /***
     * 添加订单
     */
    @PostMapping
    public int save(@RequestBody OrderInfo orderInfo) throws NacosException {
        return orderService.save(orderInfo);
    }

    /**
     * 查询订单信息
     */
    @GetMapping(value = "/one/{id}")
    public OrderInfo one(@PathVariable(value = "id")Integer id){
        return orderService.one(id);
    }
}

